<template>
  <div>
    我是index
    <p>{{2 | formatMoney}}</p>
    <br>
    <router-link to="/index" active-class="aaa">index</router-link>
    <br>
    <router-link :to="'/hello?time='+time+'&name=jack'" active-class="aaa">hello</router-link>
    <!-- <router-link :to="{path: '/hello', query: {time: time, name:'jack'}}" active-class="aaa">hello</router-link> -->
    <!-- <img src="../assets/daifahuo.svg" width="80" alt=""> -->
    <hr>
    <button @click="jump('/index')">index</button>
    <button @click="jump('/hello')">hello</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      time: '6-29'
    }
  },
  created() {
    document.title = this.$route.meta.title
  },
  mounted() {
    // console.log(this.$route);
  },
  // 路由进入之前
  beforeRouteEnter:((to, from, next) => {
    // to and from are both route objects. must call `next`.
    console.log(to);
    console.log(from);
    next()
  }),
  methods: {
    jump(url) {
      // 和router-link的区别：可以在函数中添加逻辑代码，比如判断登录、权限校验等
      // this.$router.push(url+'?time='+this.time+'&name=jack');
      this.$router.push({
        path: url,
        query: {
          time: this.time,
          name: 'jack'
        }
      });
    }
  }
}
</script>

<style>

</style>